package cn.laixueit.controller;

import cn.laixueit.pojo.item.SpecParam;
import cn.laixueit.service.SpecParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;

@Controller
@RequestMapping("/spec")
public class SpecParamController {

    @Autowired
    private SpecParamService specParamService;

    @GetMapping("/params")
    public ResponseEntity<Collection<SpecParam>> params(@RequestParam(value = "gid",required = false) Long gid,
                                                        @RequestParam(value = "cid",required = false) Long cid,
                                                        @RequestParam(value = "searching",required = false) Boolean searching,
                                                        @RequestParam(value = "generic",required = false) Boolean generic){
        Collection<SpecParam> specParams = specParamService.findList(gid,cid,searching,generic);
        return ResponseEntity.ok(specParams);
    }
}
